#define F_CPU 8000000UL

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <string.h>
#include <math.h>

//#define DEBUGON
// Uncomment if Pong acts as a slave, not needed for nunchcuck
#define TWISLAVEON 
//#undef TWISLAVEON


#ifdef DEBUGON
  #include "rs232c.h"
#endif

#include "fonts.h"
#include "display.h"
#include "fonts.h"
#include "nunchuck.h"



// Define TWI parameters
#define TWI_BUFFER_LENGTH 8


#define GetPixel(x,y) gLEDs[x]&(1<<(SHEIGHT-1-y))     /* Macro: "Pixel" status read */
#define SetPixel(x,y) gLEDs[x]|=1<<(SHEIGHT-1-y)      /* Macro: "Pixel" set */
#define XorPixel(x,y) gLEDs[x]^=1<<(SHEIGHT-1-y)      /* Macro: "Pixel" set */
#define ClearPixel(x,y) gLEDs[x]&=~(1<<(SHEIGHT-1-y)) /* Macro: "Pixel" clear */

#ifndef GAMETIMES
#define GAMETIMES 20000
volatile uint16_t gametime = 20000;
#endif

#ifndef HUNTDELAYS
#define HUNTDELAYS 1800
#endif

volatile uint16_t huntdelay = 0;

#ifndef HUNTBLINKS
#define HUNTBLINKS 50
#endif

#ifndef huntblink
volatile uint16_t huntblink = HUNTBLINKS;
#endif

#ifndef BALLSPD
#define BALLSPD 200
uint16_t BallSpeed = BALLSPD;  			// Initial speed of the ball 
volatile uint16_t BallDelay;			// Delay counter for ball speed calculation 
#endif

typedef struct Ball_S  							// Curent position of the ball 
{
 	int16_t x;
	int16_t y;
} BallType;



